import { defineStore } from "pinia";

let store = defineStore("DeptStore", {
    state: () => {
        return  {
            deptno: 0,
            dname:'',
            locid: 0
        }
    },
    getters: {
        getDeptno: function (state){
            return state.deptno;
        },
        getDname: function (state){
            return state.dname;
        },
        getLocid: function(state){
            return state.locid;
        },
        getDeptInfo: function(state){
            return state;
        }
    },
    actions: {
        saveDeptno: function (deptno: number){
            this.deptno = deptno;
        },
        saveDname: function(dname: string){
            this.dname = dname;
        },
        saveLocid: function(locid: number){
            this.locid = locid;
        },
        savaDeptInfo: function(obj: any){
            this.$state = obj;
        }
    },
    persist: {
        storage: sessionStorage
    } 
})

export default store;